
Function CreateLight:Int(lightType:Int = LT_POINT)
	Local obj:B3DEntity = New B3DEntity
	Local l:Light = getSceneManager().CreateLight()
	l.setType(lightType)
	l.setSpecularColour(1.0, 1.0, 1.0)
	
	obj.obj 	= l
	obj._typ	= l._typ
	getBlitz3D()._AddEntity(l.getName(), obj)
	
	Return HandleFromObject(obj)
End Function


Function LightColor(l:Int, r:Float, g:Float, b:Float)
	Local obj:B3DEntity = B3DEntity(HandleToObject(l))
	Light(obj.obj).setDiffuseColour(r, g, b)
End Function


Function LightSpecColor(l:Int, r:Float, g:Float, b:Float)
	Local obj:B3DEntity = B3DEntity(HandleToObject(l))
	Light(obj.obj).setSpecularColour(r, g, b)
End Function


Function LightRange(l:Int, rng:Float = 1000.0)
	Local obj:B3DEntity = B3DEntity(HandleToObject(l))
	
	Select obj._typ
		Case LT_SPOTLIGHT	; Light(obj.obj).setSpotlightRange(rng, rng)
		Case LT_POINT		; Light(obj.obj).setAttenuation(rng, 1.0, 0.007, 0.0)
	End Select
End Function


Function LightConeAngles(spotlight:Int, innerAngle:Float = 0, outerAngle:Float = 90)
	Local obj:B3DEntity = B3DEntity(HandleToObject(spotlight))
	Light(obj.obj).setSpotlightRange(innerAngle, outerAngle)
End Function


Function LightShadowRange(l:Int, nearShadowDistance:Float = 0.1, farShadowDistance:Float = 100.0)
	Local obj:B3DEntity = B3DEntity(HandleToObject(l))
	Light(obj.obj).setShadowNearClipDistance(nearShadowDistance)
	Light(obj.obj).setShadowFarClipDistance(farShadowDistance)
End Function